package com.cetcs.kmga.dataManager.service.impl.device;

import com.cetc.cloud.kmga.util.SigarUtils;
import com.cetcs.kmga.common.Data;
import com.cetcs.kmga.common.Page;
import com.cetcs.kmga.dataManager.dao.mybatis.AuditManagerMapper;
import com.cetcs.kmga.dataManager.dao.mybatis.CleanRecordLogMapper;
import com.cetcs.kmga.dataManager.dao.mybatis.SysManagerMapper;
import com.cetcs.kmga.dataManager.entity.device.DeviceInfo;
import com.cetcs.kmga.dataManager.entity.device.Resrc;
import com.cetcs.kmga.dataManager.entity.device.ResrcAuditObj;
import com.cetcs.kmga.dataManager.entity.device.ResrcAuditObjNocnct;
import com.cetcs.kmga.dataManager.entity.sysManager.LocalServerInfo;
import com.cetcs.kmga.dataManager.entity.sysManager.vo.ServerStatusVo;
import com.cetcs.kmga.dataManager.schedule.InitCdTypeListener;
import com.cetcs.kmga.dataManager.service.device.AuditService;
import com.cetcs.kmga.dataManager.service.sysManager.SysManagerService;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.google.common.collect.Lists;
import org.hyperic.sigar.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * Created by yyangs on 2017/2/14.
 */
@Service
public class AuditServiceImpl implements AuditService {

    @Autowired
    private AuditManagerMapper auditManagerMapper;
    @Autowired
    private InitCdTypeListener initCdTypeListener;


    /**
     *查询待确定资源的审计信息 根据条件
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public List<ResrcAuditObjNocnct> getAllResrcAuditObjNocnctByCondition(Data dataMap) throws Exception {
//        return auditManagerMapper.getAllResrcAuditObjNocnctByCondition(dataMap);
        return null;
    }

    /**
     *新增 待确定的资源审计信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer createResrcAuditObjNocnct(Data dataMap) throws Exception {
//        return auditManagerMapper.createResrcAuditObjNocnct(dataMap);
        return null;
    }

    /**
     *修改待确定的资源审计信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer updateResrcAuditObjNocnct(Data dataMap) throws Exception {
//        return auditManagerMapper.updateResrcAuditObjNocnct(dataMap);
        return null;
    }

    /**
     *删除待确定的资源审计信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer deleteResrcAuditObjNocnct(Data dataMap) throws Exception {
//        return auditManagerMapper.deleteResrcAuditObjNocnct(dataMap);
        return null;
    }

    /**
     *对比带确定的资源审计信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer createOrUpdateResrcAuditObjNocnct(Data dataMap) throws Exception {
//        Integer result = 0;
//        Data params = new Data();
//        params.put("serverIp",dataMap.getString("serverIp"));
//        params.put("port",dataMap.getString("port"));
//        List<ResrcAuditObjNocnct> resrcAuditObjNocncts = auditManagerMapper.getAllResrcAuditObjNocnctByCondition(params);
//        if(resrcAuditObjNocncts==null || resrcAuditObjNocncts.size()==0){
//            //不存在 则添加
//            result += auditManagerMapper.createResrcAuditObjNocnct(dataMap);
//        }else{
//            //存在  修改
//            result += auditManagerMapper.updateResrcAuditObjNocnct(dataMap);
//        }
//        return result;
        return null;
    }

    /**
     *查询数据资源信息 根据条件
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public List<Resrc> getAllResrcByCondition(Data dataMap) throws Exception {
//        return auditManagerMapper.getAllResrcByCondition(dataMap);
        return null;
    }

    /**
     *新增数据资源信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer createResrc(Data dataMap) throws Exception {
        Integer result = 0;
        result = auditManagerMapper.createResrc(dataMap);
        if(result>0){
            initCdTypeListener.reloadResourceIn2CodeTb();
        }
        return result;
    }

    /**
     *修改数据资源信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer updateResrc(Data dataMap) throws Exception {
        //return auditManagerMapper.updateResrc(dataMap);
        Integer result = 0;
        result = auditManagerMapper.updateResrc(dataMap);
        if(result>0){
            initCdTypeListener.reloadResourceIn2CodeTb();
        }
        return result;
    }

    /**
     *删除数据资源信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer deleteResrc(Data dataMap) throws Exception {
        //return auditManagerMapper.deleteResrc(dataMap);
        Integer result = 0;
        result = auditManagerMapper.deleteResrc(dataMap);
        if(result>0){
            initCdTypeListener.reloadResourceIn2CodeTb();
        }
        return result;
    }




    /**
     *对比数据资源信息 根据条件
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer createOrUpdateResrc(Data dataMap) throws Exception {
//        Integer result = 0;
//        Data params = new Data();
//        params.put("id",dataMap.getInt("id"));
//        List<Resrc> resrcs = auditManagerMapper.getAllResrcByCondition(params);
//        if(resrcs==null || resrcs.size()==0){
//            //不存在 则添加
//            result += auditManagerMapper.createResrc(dataMap);
//        }else{
//            //存在  修改
//            result += auditManagerMapper.updateResrc(dataMap);
//        }
//        return result;
        return null;
    }


    /**==========数据资源审计对象信息=========**/

    /**
     *查询数据资源审计对象信息 根据条件
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public List<ResrcAuditObj> getAllResrcAuditObjByCondition(Data dataMap) throws Exception {
//        return auditManagerMapper.getAllResrcAuditObjByCondition(dataMap);
        return null;
    }

    /**
     *新增数据资源审计对象信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer createResrcAuditObj(Data dataMap) throws Exception {
        return auditManagerMapper.createResrcAuditObj(dataMap);
    }

    /**
     *修改数据资源审计对象信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer updateResrcAuditObj(Data dataMap) throws Exception {
        return auditManagerMapper.updateResrcAuditObj(dataMap);
    }

    /**
     *删除数据资源审计对象信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer deleteResrcAuditObj(Data dataMap) throws Exception {
        return auditManagerMapper.deleteResrcAuditObj(dataMap);
    }

    /**
     *对比数据资源审计对象信息
     * @param dataMap
     * @return
     * @throws Exception
     */
    @Override
    public Integer createOrUpdateResrcAuditObj(Data dataMap) throws Exception {
//        Integer result = 0;
//        Data params = new Data();
//        params.put("id",dataMap.getString("id"));
//        List<ResrcAuditObj> resrcAuditObjNocncts = auditManagerMapper.getAllResrcAuditObjByCondition(params);
//        if(resrcAuditObjNocncts==null || resrcAuditObjNocncts.size()==0){
//            //不存在 则添加
//            result += auditManagerMapper.createResrcAuditObj(dataMap);
//        }else{
//            //存在  修改
//            result += auditManagerMapper.updateResrcAuditObj(dataMap);
//        }
//        return result;
        return null;
    }
}
